package com.wangshili.common.bo;

import java.io.Serializable;
import java.util.List;

/**
 * 封装分页实体信息bo对象
 * @author wangshili
 *
 * @param <T> 页面实体类
 */
public class PageObject<T> implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3736205593370676255L;

	/**当前页的页码值*/

	private Integer pageCurrent;

	/**页面大小*/

	private Integer pageSize;

	/**总记录数(通过查询获得)*/

	private Integer rowCount;

	/**总页数(通过计算获得)*/

	private Integer pageCount;

	/**当前页记录*/

	private List<T> records;

	public PageObject(){}//无参构造

	public PageObject(Integer pageCurrent, Integer pageSize, Integer rowCount, List<T> records) {

		super();

		this.pageCurrent = pageCurrent;

		this.pageSize = pageSize;

		this.rowCount = rowCount;

		this.records = records;
		//***************一般来说不允许在实体类里面写业务逻辑，尽量在别的地方计算***************

		//           this.pageCount=rowCount/pageSize;

		//           if(rowCount%pageSize!=0) {

		//                   pageCount++;

		//           }

		this.pageCount=(rowCount-1)/pageSize+1;

	}

	public Integer getPageCurrent() {

		return pageCurrent;

	}

	public void setPageCurrent(Integer pageCurrent) {

		this.pageCurrent = pageCurrent;

	}

	public Integer getPageSize() {

		return pageSize;

	}

	public void setPageSize(Integer pageSize) {

		this.pageSize = pageSize;

	}

	public Integer getRowCount() {

		return rowCount;

	}

	public void setRowCount(Integer rowCount) {

		this.rowCount = rowCount;

	}

	public Integer getPageCount() {

		return pageCount;

	}

	public void setPageCount(Integer pageCount) {

		this.pageCount = pageCount;

	}

	public List<T> getRecords() {

		return records;

	}

	public void setRecords(List<T> records) {

		this.records = records;

	}

	@Override
	public String toString() {
		return "PageObject [pageCurrent=" + pageCurrent + ", pageSize=" + pageSize + ", rowCount=" + rowCount
				+ ", pageCount=" + pageCount + ", records=" + records + "]";
	}


}
